﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GASS.CUDA.Types;

namespace Visualizator.Physics
{
    /// <summary>
    /// El integrador Verlet que corre el algoritmo completamente
    /// en el CPU.
    /// </summary>
    public class CPUVerletIntegrator: IVerletIntegrator
    {
        public Float4[] Pos { get; set; }
        public Float4[] PrevPos { get; set; }

        public int ParticleCount { get; set; }

        public void Integrate(float dt)
        {
            Debug.Assert(Pos.Length >= ParticleCount);
            Debug.Assert(PrevPos.Length >= ParticleCount);

            for (int i = 0; i < ParticleCount; i++)
            {
                Float4 aux = Pos[i];
                Pos[i] = Util.SubF4(Util.AddF4(aux, aux), PrevPos[i]);
                PrevPos[i] = aux;
            }
            
        }

        public void Initialize() { }


    }
}
